package cn.edu.scnu.controller;

import cn.edu.scnu.entity.MovieDetails;
import cn.edu.scnu.service.MovieRankService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MovieRankController {

    @Autowired
    private MovieRankService movieRankService;

    /**
     * 获取电影排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank")
    public Page<MovieDetails> getMovieRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getMovieDetailsPage(page, size);
    }

    /**
     * 获取当周电影排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank/weekly")
    public Page<MovieDetails> getWeeklyRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getWeeklyRankPage(page, size);
    }

    /**
     * 获取当月电影排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank/monthly")
    public Page<MovieDetails> getMonthlyRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getMonthlyRankPage(page, size);
    }

    /**
     * 获取好评电影排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank/likes")
    public Page<MovieDetails> getLikeRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getLikesRankPage(page, size);
    }

    /**
     * 获取热门电影排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank/hot")
    public Page<MovieDetails> getHotRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getHotRankPage(page, size);
    }

    /**
     *电影总排行榜
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/movie-rank/total")
    public Page<MovieDetails> getTotalRankPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "40") int size) {
        return movieRankService.getTotalRankPage(page, size);
    }
}
